import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:sainbainu/common/routes/routes.dart';
import 'package:sainbainu/common/widgets/widget.dart';
import 'package:sainbainu/view/home/home_follow/index.dart';
import 'package:sainbainu/view/home/home_recommend/index.dart';

import 'index.dart';

class HomePage extends GetView<HomeController> {
  const HomePage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GetBuilder<HomeController>(
      builder: (_) {
        return Scaffold(
          appBar: CustomAppBarWidget(
            tabController: _.state.tabController,
            tabs: [
              Tab(text: '推荐'.tr),
              Tab(text: '关注'.tr),
            ],
            showSearchIcon: true,
            onSearchTap: () => Get.toNamed(AppRoutes.globalSearch),
          ),
          body: TabBarView(
            controller: _.state.tabController,
            children: const [
              KeepAliveWrapperWidget(
                child: HomeRecommendPage(),
              ),
              KeepAliveWrapperWidget(
                child: HomeFollowPage(),
              ),
            ],
          ),
        );
      },
    );
  }
}
